<include file="../header" />
<script type="text/javascript">
    function del(id, name) {
        if (!confirm("是否删除员工【" + name + "】")) {
            return false;
        }
        var url = "/admin/User/delete?id=" + id;
        window.location.href = url;
    }
</script>
<style type="text/css">
	.btn-danger,.btn-info,.btn-success,.btn-warning{
		width: 60px;
		/*height: 18px;*/
		padding: 2px 0px 2px 0px;
		margin: 1px 0px 1px 0px;
	}
</style>
<body class="J_scroll_fixed">
	<div class="wrap J_check_wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:U('user/employee')}">员工管理</a></li>
			<li><a href="{:U('user/add')}">添加员工</a></li>
		</ul>
		<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th >头像</th>
					<th >状态</th>
					<th >信息</th>
					<th >部门</th>
					<th >渠道</th>
					<!--<th>最后登录时间</th>-->
					<!--<th>最后登录时间</th>-->
					<!--<th>E-mail</th>-->
					<!--<th>状态</th>-->
					<th >备注</th>
					<th >管理操作</th>
				</tr>
			</thead>
			<tbody>
				<php>
					$user_statuses=array("0"=>"停用","1"=>"启用","2"=>"未验证");
					$agentList = D('Agent')
					->where(array('enterprise_code'=>$user['enterprise_code']))
					->select();
				</php>
				<foreach name="users" item="vo">
				<tr>
					<td style="width:70px;"><img src="{$vo.headimgurl}"/></td>
					<if condition = "$vo['granted'] eq '1'">
						<td style="width:70px;color: #1cc385">已审批</td>
					<else/>
						<td style="width:70px; color: #df6b5f">待审批</td>
					</if>
					<td style="min-width:100px;width:300px;">
						企业：<a style="color: #00a0e9">{$vo.enterprise_name}</a>（{$vo.enterprise_code}）<br/>
						姓名：<a style="font-weight: bold" href='{:U("user/updateInfo",array("id"=>$vo["employee_id"]))}'>{$vo.admin_name}</a> <br/>
						用户名：{$vo.name} ({$vo.employee_id})
					</td>
					<td style="min-width:100px;width:400px;color: #00a0e9">
						<php>
							$roleList = explode(',', $vo["role"]);
							$i = 0;
							foreach($allRoleList as $role) {
								if (in_array($role["id"], $roleList)) {
									if($i != 0){
									if($i != 7){
									echo("、 ");
									}else{
									echo("<br/>");
									}
									}
									echo($role["name"]);
									$i++;
								}
							}
						</php>
					</td>
					<php>
						$agentStr = "";
						$agentIdArr = explode(",", $vo["agent_id"]);

						foreach ($agentList as $c) {
						if(in_array($c['agent_id'], $agentIdArr)){
						if(!isNullOrEmpty($agentStr)){
						$agentStr .= "、   ";
						}
						$agentStr .= $c['agent_name'];
						}
						}
					</php>
					<td style="min-width:100px; width: 400px;color: #1cc385">{$agentStr}</td>
					<!--<td>-->
						<!--<if condition="$vo['last_login_time'] eq 0">-->
							<!--该用户还没登陆过-->
						<!--<else />-->
							<!--{$vo.last_login_time}-->
						<!--</if>-->
					<!--</td>-->
					<!--<td>{$vo.user_email}</td>-->
					<!--<td>{$user_statuses[$vo['user_status']]}</td>-->
					<td style="width:300px; color: #df6b5f">{$vo.note}</td>
					<td style="width:70px;">
						<if condition="$vo['user_id'] eq 1">
							<a class="btn btn-info" disabled="disable">修改</a>
							<!--<if condition="$vo['user_status'] eq 1">-->
								<!--<font color="#cccccc">停用</font>-->
							<!--<else />-->
								<!--<font color="#cccccc">启用</font>-->
							<!--</if>-->
						<else />
							<a class="btn btn-info" href='{:U("user/edit",array("id"=>$vo["user_id"]))}'>修改</a>
							<!--<if condition="$vo['user_status'] eq 1">-->
								<!--<a href="{:U('user/ban',array('id'=>$vo['userid']))}" class="J_ajax_dialog_btn" data-msg="您确定要停用此用户吗？">停用</a>-->
							<!--<else />-->
								<!--<a href="{:U('user/cancelban',array('id'=>$vo['userid']))}" class="J_ajax_dialog_btn" data-msg="您确定要启用此用户吗？">启用</a>-->
							<!--</if>-->
						</if>
						<br/>
						<if condition="$vo['user_id'] eq 1 || $vo['user_id'] eq $user['user_id']">
							<a class="btn btn-danger" disabled="disable">删除</a>
							<else />
							<a class="btn btn-danger" onclick='javascript:del("{$vo.user_id}","{$vo.admin_name}",0)'>删除</a>
						</if>
					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
		<div class="pagination">{$page}</div>
	</div>
	<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>